package api

import (
	"gitee.com/alex_li/upload/internal/etc"
	"github.com/lishimeng/app-starter"
	"github.com/lishimeng/app-starter/server"
)

type AdminReq struct {
	Enable int `json:"enable"`
}

func autoClear(ctx server.Context) {

	var resp app.Response
	var req AdminReq
	err := ctx.C.ReadJSON(&req)
	if err != nil {
		resp.Code = 500
		ctx.Json(resp)
		return
	}

	if req.Enable == 1 {
		etc.Config.AuthClear.Enable = true
	} else {
		etc.Config.AuthClear.Enable = false
	}

	resp.Code = 0
	resp.Message = "success"
	ctx.Json(resp)
}
